package com.blog.anxinzhu.dubbo.api.service;

import com.alibaba.dubbo.config.annotation.Reference;
import com.blog.anxinzhu.dubbo.api.vo.Pagination;
import com.blog.anxinzhu.dubbo.api.vo.TableResult;
import com.blog.anxinzhu.dubbo.service.api.ApiHouseResourcesService;
import com.blog.anxinzhu.dubbo.service.pojo.HouseResources;
import com.blog.anxinzhu.dubbo.service.vo.PageInfo;
import org.springframework.stereotype.Service;

/**
 * @author chenlin
 * @create 2020-12-02  15:00
 * 消费方 调用dubbo提供的服务
 */
@Service
public class HouseResourcesService {
    @Reference(version = "1.0.0")
    ApiHouseResourcesService apiHouseResourcesService;

    public boolean save(HouseResources houseResources){
        int result = apiHouseResourcesService.saveHouseResources(houseResources);
        return result == 1;
    }

    public TableResult queryList(HouseResources houseResources, Integer currentPage,
                                 Integer pageSize) {
        PageInfo<HouseResources> pageInfo = this.apiHouseResourcesService.
                queryHouseResourcesList(currentPage, pageSize, houseResources);
        return new TableResult(pageInfo.getRecords(),
                new Pagination(currentPage, pageSize, pageInfo.getTotal()));
    }

    public HouseResources queryHouseResourcesById(Integer id){
        return apiHouseResourcesService.queryHouseResourcesById(id);
    }
}
